package com.lyz.stringdemo;

/**
 * @ClassName Demo6x
 * @Description String常用API
 * @Author 2214361854
 * @Date 2022/2/15 22:51
 * @Version 1.0
 */
public class Demo1 {
    public static void main(String[] args) {
        String name1 = "Java语言编程";
        String name2 = "java语言编程";

        //name3 编译器优化为"java语言编程"
        String name3 = "java"+"语言编程";

        System.out.println(name1.length());
        System.out.println(name1.equals(name2));
        System.out.println(name1.equalsIgnoreCase(name2));
        System.out.println(name2.equalsIgnoreCase(name3));
        System.out.println(name1);
        System.out.println(name1.charAt(2));
        char[] name4 = name1.toCharArray();
        System.out.println(name4[2]);
        System.out.println(name1.substring(4));
        System.out.println(name1.substring(0,4));
        String name5 = name1.replace("Java","JAVA");
        System.out.println(name5);

        //精准判断是否以该内容开始，返回布尔
        System.out.println(name1.startsWith("java"));
        System.out.println(name1.startsWith("Java"));

        //精准匹配是否包含内容，返回布尔
        System.out.println(name1.contains("java"));
        System.out.println(name1.contains("Java"));

        //字符全部转大写
        String daxiezm = "abcdefgPQRSTUVWXY 字母全部转大写";
        System.out.println(daxiezm.toUpperCase());

        //字符串比较
        String a = "小王";
        String b = "小强";
        System.out.println(a.equals(b));
    }
}
